package com.cms;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class Generator {

    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://47.99.176.131:3306/kerong-cms?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false&serverTimezone=UTC", "root", "Mr999999")
                .globalConfig(builder -> {
                    builder/*.author("")*/ // 设置作者
//                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("C:/src"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.cms") // 设置父包名
                            .moduleName("") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "C:/src/com/cms/mapper/xml")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("cms_admin","cms_admin_role","cms_category","cms_company","cms_content","cms_div"
                    ,"cms_div_field","cms_friend_link","cms_guestbook","cms_menu","cms_model","cms_model_field","cms_nav",
                            "cms_role","cms_role_site","cms_setup","cms_site","cms_slide","cms_tag","cms_web","cms_wechat_menu") // 设置需要生成的表名
                            .addTablePrefix("cms_"); // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();

    }

}
